package dao

import "WORKSPACE/models"

func GetallDetails() (error, []models.Order_details, int64) {
	var detailsData []models.Order_details
	var total int64
	err := db.Table("order_details").Where("is_del = false").Order("order_details_id ASC").Count(&total).Find(&detailsData).Error
	return err, detailsData, total
}

func AddDetails(detailsData models.Order_details) error {
	err := db.Table("order_details").Create(&detailsData).Error
	return err
}

func Updatedetails(detailsdata models.Order_details) error {
	err := db.Table("order_details").Where("order_details_id = ?", detailsdata.Order_details_id).Updates(&detailsdata).Error
	return err
}

func Deldetails(orderId string) error {
	err := db.Table("order_details").Where("order_id = ?", orderId).Update("is_del",true).Error
	return err
}